﻿<UserControl x:Class="QuailDashboard.View.Controls.LogEntriesControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:c1grid="clr-namespace:C1.Silverlight.DataGrid;assembly=C1.Silverlight.DataGrid" 
    xmlns:Converters="clr-namespace:QuailDashboard.View.Converters" 
    >
    <UserControl.Resources>
        <Converters:EntryTextIconConverter x:Key="EntryTextIconConverter" />
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
            <c1grid:C1DataGrid 
                                    IsReadOnly="True"
                                    AlternatingRowBackground="Beige" 
                                    AutoGenerateColumns="False" 
                                    RowHeight="Auto"
                                    x:Name="GridLogEntries" >
                <c1grid:C1DataGrid.Columns>
                    <c1grid:DataGridTemplateColumn
                                            x:Name="SyncColumn"
                                            Width="25"
                                            Header=""
                                            CanUserResize="False">
                        <c1grid:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button Click="BtnSearch_Click" Tag="{Binding TestRunTaskId}" Height="25">
                                <Image
                                                        ToolTipService.ToolTip="Click to synchronize to the task for this log entry"
                                                        Source="{StaticResource IconSearch}"
                                                        Stretch="None"
                                                    
                                                    />
                                    </Button>
                            </DataTemplate>
                        </c1grid:DataGridTemplateColumn.CellTemplate>
                    </c1grid:DataGridTemplateColumn>
                    
                    <c1grid:DataGridTemplateColumn
                                            SortMemberPath="EntryStatusId"
                                            Width="25"
                                            Header=""
                                            CanUserResize="False">
                        <c1grid:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Image
                                                        ToolTipService.ToolTip="{Binding EntryStatusId, Converter={StaticResource StatusIdConverter}}"
                                                        Source="{Binding EntryStatusId, Converter={StaticResource StatusConverter}}"
                                                        Stretch="None"
                                                    />
                            </DataTemplate>
                        </c1grid:DataGridTemplateColumn.CellTemplate>
                    </c1grid:DataGridTemplateColumn>

                    <c1grid:DataGridTemplateColumn
                                            SortMemberPath="EntryCreateDate"
                                            CanUserFilter="False"
                                            Header="Created"
                                            MaxWidth="125">
                        <c1grid:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox
                                                        Text="{Binding EntryCreateDate, Converter={StaticResource RelativeDateConverter}}"
                                                        IsReadOnly="True"/>
                            </DataTemplate>
                        </c1grid:DataGridTemplateColumn.CellTemplate>
                    </c1grid:DataGridTemplateColumn>

                    <c1grid:DataGridTemplateColumn
                                            SortMemberPath="EntryText"
                                            Width="Auto"
                                            Header="Message">
                        <c1grid:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBox
                                                            x:Name="TextBoxMessage"
                                                            TextWrapping="Wrap"
                                                            Text="{Binding EntryText}"
                                                            HorizontalScrollBarVisibility="Auto"
                                                            VerticalScrollBarVisibility="Auto"
                                                            Width="Auto"
                                                            MaxWidth="400"
                                                            MaxHeight="120"/>
                                    <Button
                                                            x:Name="BtnPreview"
                                                            Click="BtnPreview_Click"
                                                            Tag="{Binding TestRunTaskLogEntryId}"
                                                            Height="25"
                                                            >
                                        <Image
                                                                Stretch="None"
                                                                Source="{Binding EntryText, Converter={StaticResource EntryTextIconConverter}}"
                                                                ToolTipService.ToolTip="View content" />
                                    </Button>
                                </StackPanel>
                            </DataTemplate>
                        </c1grid:DataGridTemplateColumn.CellTemplate>
                    </c1grid:DataGridTemplateColumn>

                    <c1grid:DataGridTemplateColumn
                                            SortMemberPath="Url"
                                            Header="Url"
                                            MinWidth="100"
                                            MaxWidth="275">
                        <c1grid:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox
                                                Text="{Binding Url}"
                                                />
                            </DataTemplate>
                        </c1grid:DataGridTemplateColumn.CellTemplate>
                    </c1grid:DataGridTemplateColumn>
                </c1grid:C1DataGrid.Columns>
            </c1grid:C1DataGrid>
        </ScrollViewer>
    </Grid>
</UserControl>
